package javbot.gui;

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.Rectangle;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;

public class HtmlPanel extends JPanel {

	private static final long serialVersionUID = 5370585713328033836L;
	private JTextPane jTextPane = null;  //  @jve:decl-index=0:visual-constraint="174,45"
	private JScrollPane jScrollPane = null;
	private final String panelText;
	private Font font = new Font("DialogInput", Font.PLAIN,12);
	
	/**
	 * This is the default constructor
	 */
	public HtmlPanel(String panelText) {
		super();
		this.panelText = panelText;
		initialize();
		jTextPane.setCaretPosition(0);
	}
	
	public void scrollToTop() {
		jScrollPane.getViewport().scrollRectToVisible(new Rectangle(0,0,50,50));
	}
	
	

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setLayout(new BorderLayout());
		this.setSize(new java.awt.Dimension(148,130));
		this.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
	}

	/**
	 * This method initializes jTextPane	
	 * 	
	 * @return javax.swing.JTextPane	
	 */
	private JTextPane getJTextPane() {
		if (jTextPane == null) {
			jTextPane = new JTextPane();
			jTextPane.setFont(font);
			jTextPane.setContentType("text/html");			
			jTextPane.setText(panelText);
			jTextPane.setEditable(false);
		}
		return jTextPane;
	}

	/**
	 * This method initializes jScrollPane	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getJScrollPane() {
		if (jScrollPane == null) {
			jScrollPane = new JScrollPane(getJTextPane());
		}
		return jScrollPane;
	}

}  //  @jve:decl-index=0:visual-constraint="1,10"
